/**
 * 
 */
package cn.edu.bjtu.entity.impl.lightweight;

import java.io.InputStream;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;

import pojo.dto.services.TCAddDocumentResult;

/**
 * @author alex
 *
 */
public class TCAddDocumentAPI extends BaseDefaultConfiged<TCAddDocumentResult> {
	String doc = null;
	String label = null;
	public TCAddDocumentAPI(HttpServletRequest req) {
		doc = req.getParameter("doc");
		label = req.getParameter("label");
	}

	@Override
	public URI getURI() {
		return URI.create("/cnn/update");
	}
	public HttpEntity getPostEntity(){
		List<NameValuePair> l = new ArrayList<NameValuePair>();
		l.add(new BasicNameValuePair("doc", this.doc));
		l.add(new BasicNameValuePair("label", label));
		UrlEncodedFormEntity uefe = new UrlEncodedFormEntity(l,Charset.forName("utf-8"));
		return uefe;
	}
	@Override
	protected void handleResponseInputStream(InputStream in, HttpEntity entity) throws Exception {
		result = om.readValue(in, TCAddDocumentResult.class);
	}

}
